<?php

declare(strict_types=1);

namespace app\index\logic;

// 问题列表(没有分类)
// use app\common\model\Problem as ProblemModel;
use app\common\model\ProblemClassify as ProblemClassifyModel;

class Problem
{
    /**
     * 问题列表
     */
    public static function getLists(): array
    {
        $data = ProblemClassifyModel::with([
            'problem' => function ($query) {
                $query->field('id,classify_id,title,answer')
                    ->scope('sort')
                    ->visible(['title', 'answer']);
            }
        ])->field('id,name')->scope('sort')->select();
        return $data->hidden(['id'])->toArray();
    }

    /**
     * 问题列表(没有分类)
     */
    // public static function getLists(): array
    // {
    //     $data = ProblemModel::field('title,answer')->scope('sort')->select();
    //     return $data->toArray();
    // }
}
